package friend

import (
	"api/pb/friend"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateFriendGroupLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateFriendGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateFriendGroupLogic {
	return &UpdateFriendGroupLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// UpdateFriendGroup 更新好友分组信息
func (l *UpdateFriendGroupLogic) UpdateFriendGroup(req *types.FriendGroupInfo) (resp *types.Empty, err error) {
	_, err = l.svcCtx.FriendRPC.UpdateGroup(l.ctx, &friend.GroupInfo{Id: req.ID, Name: req.Name, Sort: req.Sort})
	if err != nil {
		return nil, err
	}
	return &types.Empty{}, nil
}
